package com.yfkj.common.message;


import com.yfkj.common.message.domain.SmsRecord;
import com.yfkj.common.message.domain.TaskInfo;
import com.yfkj.common.message.domain.model.EmailContentModel;
import com.yfkj.common.message.domain.sms.SmsParam;
import com.yfkj.common.message.handler.impl.EmailHandler;
import com.yfkj.common.message.script.impl.AliSmsScript;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.*;

@SpringBootTest
public class BaseTestController {

    @Autowired
    EmailHandler emailHandler;

    @Autowired
    AliSmsScript aliSmsScript;

    /**
     * 测试AliSmsScript
     */
    @Test
    public void sendSms(){
        Map<String,String> param = new HashMap<>();

        // 发送警报时间
        param.put("time", "2023-4-21");
        // 获取设备编号
        param.put("number","sss");
        // 判断设备类型
        param.put("type", "电表");
        // 写入设备位置
        param.put("position", "测试地点");


        param.put("status", "断电");
        param.put("operator", "王刚");

        Set<String> phones = new HashSet<>();
        phones.add("15394522683");

        SmsParam smsParam = SmsParam.builder()
                .param(param).phones(phones).scriptName("AliSmsScript").sendAccountCode(1)
                        .build();
        List<SmsRecord> send = aliSmsScript.send(smsParam);
        System.out.println(send);

    }

    /**
     * 发送邮件测试
     */
    @Test
    public void sendEmail(){
        Set<String> receiver = new HashSet<>();
        receiver.add("284486912@qq.com");
        EmailContentModel emailContentModel = new EmailContentModel();

        emailContentModel.setContent("你好");
        emailContentModel.setUrl("G:\\faceImg\\face\\1681694378818.jpg");
        emailContentModel.setTitle("测试邮件");
        TaskInfo taskInfo = TaskInfo.builder().contentModel(emailContentModel).receiver(receiver)
                .build();
        emailHandler.handler(taskInfo);
    }
}
